package com.zhufei.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Bbscs_UserinfoDAO extends DBCon{
	private static String TABLE = "bbscs_userinfo";
	private static String ID = "ID";
	private static String USERNAME = "UserName";
	/**
	 * 根据username返回ID
	 * @param username 用户名
	 * @return ID
	 */
	public static String getID (String username){
		DBCon con = new DBCon();
		try {
			Statement statement = con.getStatement();
			String sql = "select "+ID+" from "+TABLE+" where "+USERNAME+"='"+username+"'";
			ResultSet rs = statement.executeQuery(sql);
			if(rs.next()){
				String s = rs.getString(ID);
				rs.close();
				return s;
				
			}else{
				rs.close();
				return null;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			con.closeDB();
		}
		return null;
	}
}
